import { addTypeDao, delTypeDao, findAllTypeDao, findTypeByPageDao, getAllCountDao, updateTypeDao } from "../Dao/typeDao.js"


export const addTypeServ =async (name,color) =>{
    await addTypeDao(name,color);
    return{
        code:0,
        msg:"add OK"
    }
}


export const deleteTypeServ =async (id) =>{
    await delTypeDao(id);
    return{
        code:0,
        msg:"Delete OK"
    }
}

export const updateTypeServ =async (id,obj) =>{
    await updateTypeDao(id,obj);
    return{
        code:0,
        msg:"update OK"
    }
}


export const findAllTypeServ =async () =>{
    const data =await findAllTypeDao()
    return{
        data,
        code:0,
        msg:"all type"
    }
}

export const findTypeByPageServ =async (page,size) =>{
    const data =await findTypeByPageDao(page,size);
    const total = await getAllCountDao()
    return{
        code:0,
        msg:"findPage",
        data:{
            total,
            data
        }
    }
}